import builtins
from _datetime import datetime
import os
from com.yc.study.CardDo import CardDo

global a
a = 1000
def test_set_object_prop():
    card_list = []
    card = CardDo()
    card.set_card_id('111111')
    print(card.get_card_id())
    card_list.append(card)
    card_list.extend("for")
    print(card_list.__len__())
    print(card_list[0].get_card_id())
    print(card_list[1])
    print(card_list[2])
    print(card_list[3])
    if card in card_list:
        print("已存在ID：", card.get_card_id())
    card_list.remove(card)
    print(card_list)
    card_list.append(card)
    print(card_list)
    str = card_list.pop(1)
    print(str)
    card_list.remove("f")
    print(card_list)
    test_dict = dict()
    test_dict.setdefault("key", "value")
    v = test_dict.get("key")
    if v == "value":
        print("v is exits,value is", v)
    v = test_dict.get("value")
    if v is None:
        print("value not exist")
    del test_dict["key"]
    print(test_dict)
    tua = (1, 2, 3, 4, 56)
    print(tua)
    print(tua.__contains__(1))
    print("tua[1]:%d" % tua[1])
    s1 = {'a', 'b', 'c', 'd'}
    s2 = {'e', 'f', 'g', 'h', 'd'}
    v = s1 & s2
    if v == set():
        print("empty set")
    else:
        print(v)
    tub = (1,2,3,4,5)
    list_a = list(tub)
    print(list_a)
    global a
    a = 100
    print(a)
    print_global_a()
    print(dir(builtins))#builtins里面大写字母开头表示内置常量名，消息字母开头表示内置函数名
    unpack_dict()
    time_demo()
    e = 2000
    print(id(e),e)
    f = e
    print(id(f),f)
def print_global_a():
    print(f"print_global_a :{a}")

def unpack_dict():
    conn_params = {
        "dbname": "skqs",
        "user": "skqsdb",
        "password": "skqs!@#$",
        "port": "5432",
        "host": "hz.biot.shimge.com"
    }
    print("单星号拆包",*conn_params)
    try:
        a  = 20
        # print(**conn_params)
    except Exception as e:
        print(e.__cause__,e)
    else:
        print("异常未发生",a)
    finally:
        print("最终打印")

def time_demo():
    now = datetime.now()
    print("当前时间：",now.strftime("%Y-%m-%d %H:%M:%S"))

if __name__ == '__main__':
    test_set_object_prop()
